/*
 * Created on 2004-04-26
 */
package org.opencube.data;

import java.io.Serializable;
import java.util.Arrays;
import java.util.LinkedList;

/**
 * @author <a href="mailto:maciek@fingo.pl">FINGO - Maciej Mroczko</a>
 */
public class RecordSet implements Serializable
{
	private RecordSetMetaData metaData = new RecordSetMetaData();
	private LinkedList<Record> records = new LinkedList<Record>();

	/**
	 * @return
	 */
	public Record[] getRecords()
	{
		return this.records == null ? null : this.records.toArray( new Record[this.records.size()] );
	}

	/**
	 * @param values
	 */
	public void setRecords( Record[] records )
	{
		if( records == null )
		{
			this.records = null;
		}
		else
		{
			this.records = new LinkedList<Record>( Arrays.asList( records ) );
		}
	}

	/**
	 * @return
	 */
	public RecordSetMetaData getMetaData()
	{
		return this.metaData;
	}

	/**
	 * @param metaData
	 */
	public void setMetaData( RecordSetMetaData metaData )
	{
		this.metaData = metaData;
	}

	public void addRecord( Record record )
	{
		if( this.records == null )
		{
			this.records = new LinkedList<Record>();
		}
		this.records.add( record );
	}

	public int getRecordsCount()
	{
		return this.records == null ? 0 : this.records.size();
	}
}
